//
//  CinemaTableViewCell.m
//  Fengly_Nuo_Movie
//
//  Created by dllo on 16/1/3.
//  Copyright © 2016年 Fengly_Nuo. All rights reserved.
//

#import "CinemaTableViewCell.h"

// MARK:VIEW_CENTER_X:屏中心x轴
#define VIEW_CENTER_X self.contentView.center.x

// MARK:VIEW_CENTER_Y:屏中心y轴
#define VIEW_CENTER_Y self.contentView.center.y

// MARK:HEIGHT:屏高
#define HEIGHT self.contentView.frame.size.height

// MARK:WIDTH:屏宽
#define WIDTH self.contentView.frame.size.width

#define kMyViewWidth _myView.frame.size.width
#define kMyViewHeight _myView.frame.size.height

@interface CinemaTableViewCell()

@property (nonatomic, retain) UIView *myView;
@property (nonatomic, retain) UIImageView *myIamgeView;
@property (nonatomic, assign) CGRect rectAddress;
@property (nonatomic, assign) CGRect rectcinemaName;
@property (nonatomic, assign) CGRect rectTelephone;

@end

@implementation CinemaTableViewCell

- (void)dealloc {
    [_myView release];
    [_myIamgeView release];
    [_labelAddress release];
    [_labelCinemaName release];
    [_labelTelephone release];
    [_model release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        [self self_adaptionHeight];
        [self createCinemaCell];
    }
    return self;
}


- (void)createCinemaCell {
    self.myView = [[UIView alloc] init];
    [self.contentView addSubview:_myView];
    [_myView release];
    
    self.myIamgeView = [[UIImageView alloc] init];
    [_myView addSubview:_myIamgeView];
    [_myIamgeView release];
    
    self.labelCinemaName = [[UILabel alloc] init];
    [_myView addSubview:_labelCinemaName];
    [_labelCinemaName release];
    
    self.labelAddress = [[UILabel alloc] init];
    [_myView addSubview:_labelAddress];
    [_labelAddress release];
    
    self.labelTelephone = [[UILabel alloc] init];
    [_myView addSubview:_labelTelephone];
    [_labelTelephone release];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _myView.frame = CGRectMake(10, 10, WIDTH - 20, HEIGHT - 20);
    
    _myIamgeView.frame = CGRectMake(0, 0, kMyViewWidth, kMyViewHeight);
    _myIamgeView.image = [UIImage imageNamed:@"bg_eventlistcell2.png"];
    
    _labelCinemaName.frame = CGRectMake(10, 10, kMyViewWidth - 20, 50);
    _labelCinemaName.font = [UIFont boldSystemFontOfSize:20];
//    _labelCinemaName.backgroundColor = [UIColor redColor];
    
    _labelAddress.frame = CGRectMake(10, 50, kMyViewWidth - 20, 80);
    _labelAddress.numberOfLines = 2;
    _labelAddress.font = [UIFont systemFontOfSize:17];
//    _labelAddress.backgroundColor = [UIColor yellowColor];
    
    _labelTelephone.frame = CGRectMake(10, 120, kMyViewWidth - 20, 40);
    _labelTelephone.font = [UIFont systemFontOfSize:17];
//    _labelTelephone.backgroundColor = [UIColor lightGrayColor];
}

//- (void)self_adaptionHeight {
//    // 求label 高度
//    // 文字的大小，描述文字大小的信息
//    NSDictionary *dicAddress = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName, nil];
//    // 通过文字大小 获取文本的高度
//    self.rectAddress = [_model.address boundingRectWithSize:CGSizeMake(WIDTH, 0) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dicAddress context:nil];
//    
//    NSDictionary *dicCinemaName = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:20], NSFontAttributeName, nil];
//    self.rectcinemaName = [_model.cinemaName boundingRectWithSize:CGSizeMake(WIDTH, 0) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dicCinemaName context:nil];
//    
//    NSDictionary *dicTelephone = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName, nil];
//    self.rectTelephone = [_model.telephone boundingRectWithSize:CGSizeMake(WIDTH, 0) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dicTelephone context:nil];
//}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
